#ifndef TD_TILE_H_
#define TD_TILE_H_

/************************************************************************/
/* STL                                                                  */
/************************************************************************/
#include <vector> 


/************************************************************************/
/* PROJECT                                                              */
/************************************************************************/
#include "Core/Coord2D.h"
#include "Core/BaseEntity.h"
#include "Core/RectangleShape.h"
 
using namespace std;
using namespace TD_Core;

namespace TD_Resources {

	enum TileType {
		invalidTile = -1,
		walkableTile,
		nonWalkableTile,
		imgTile,
		charTile
	};

	class Tile : public BaseEntity {


	protected:
		shared_ptr<SDLImage> m_pImage;
		
		/*Own tile type.*/
		TileType m_tileType; 

		Coord2D m_tileSize;

		/**The tile offset clipping*/
		SDL_Rect *m_clip;
	

		void blitSurface(SDL_Surface *const g_destSurface, SDL_Rect *g_pClippingRect = NULL) const;


	public:
		/************************************************************************/
		/* Constructors                                                         */
		/************************************************************************/
		explicit Tile();
		
		explicit Tile(const Tile &rhs);

		Tile & operator=(const Tile &rhs);

		//Initialization constructor
		Tile(Coord2D tilePosition);
		Tile(Coord2D tilePosition, Coord2D tileSize);
		Tile(Coord2D tilePosition, Coord2D tileSize , TileType g_tileType, shared_ptr<SDLImage> rootImg);
		//Initilization constructor 2 
		Tile(Coord2D tilePosition, Coord2D tileSize, TileType g_tileType, SDL_Rect *clip, shared_ptr<SDLImage> rootImg);

		~Tile();

		/************************************************************************/
		/* Access Functions                                                     */
		/************************************************************************/
		inline TileType getType() const {
			return(m_tileType);
		}

		inline shared_ptr<SDLImage> getImage() const {
			return (m_pImage);
		}

		inline void setClipping(const Coord2D &position, const Coord2D &size) {
			m_clip->x = position.x;
			m_clip->y = position.y;
			m_clip->w = size.x;
			m_clip->h = size.y;
		}

		inline SDL_Rect * getClipping() const {
			return(m_clip);
		}

		inline const Coord2D & getTileSize() const {
			return(m_tileSize);
		}
		
		/************************************************************************/
		/* Rendering                                                            */
		/************************************************************************/
		virtual void render(SDL_Surface *const g_pRenderPane, unsigned int deltaTime);

		
	
	};

}
#endif